package com.spa.application.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.spa.infrastructure.enums.dict.IBaseEnum;
import lombok.Data;

@Data
@JsonInclude
public class EnumDictDTO {

    private Integer code;

    private String desc;

    private Integer sort;

    private Integer status;


    public static <T> EnumDictDTO enumToDictDto(T t) {
        EnumDictDTO dictDTO = null;
        if (t instanceof IBaseEnum) {
            dictDTO = new EnumDictDTO();
            dictDTO.code = ((IBaseEnum) t).getCode();
            dictDTO.desc = ((IBaseEnum) t).getDesc();
            dictDTO.sort = ((IBaseEnum) t).getSort();
            dictDTO.status = ((IBaseEnum) t).getStatus();
        }
        return dictDTO;

    }

}
